package com.cn.wanxi.servlet.plate;

import com.cn.wanxi.model.PlateModel;
import com.cn.wanxi.service.INewsPlateService;
import com.cn.wanxi.service.impl.NewsPlateServiceImpl;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/newsPlateSelect")
public class NewsPlateSelectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");//请求
        resp.setCharacterEncoding("UTF-8");//响应
        INewsPlateService iNewsPlateService = new NewsPlateServiceImpl();
        List<PlateModel> list = iNewsPlateService.findAll();

        JSONArray jsonArray = JSONArray.fromObject(list);
        resp.getWriter().println(jsonArray);
    }
}
